#include "VarData.h"


VarData::VarData()
{
	
}

VarData::VarData(std::string& strData)
{
	m_strData = strData;
}

void VarData::setData(std::string& strData)
{
	m_strData = strData;
}

bool VarData::toBool()
{
	bool b;

	try
	{
		b = std::stoi(m_strData);
	}
	catch (const std::exception& e)
	{
		b = false;
	}

	return b;
}

int VarData::toInt()
{
	int n = 0;

	try
	{
		n = std::stoi(m_strData);
	}
	catch (const std::exception& e)
	{
		n = 0;
	}

	return n;
}

float VarData::toFloat()
{
	float f;

	try
	{
		f = std::stof(m_strData);
	}
	catch (const std::exception& e)
	{
		f = false;
	}

	return f;
}

double VarData::toDouble()
{
	double d;

	try
	{
		d = std::stod(m_strData);
	}
	catch (const std::exception& e)
	{
		d = 0;
	}

	return d;
}

std::string& VarData::toString()
{
	return m_strData;
}